package com.ohimy.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.ohimy.entity.User;
import com.ohimy.service.impl.UserService;

@Controller("settingAction")
public class SettingAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	@Resource(name = "userService")
	private UserService userService;

	private String tab, item;
	private String[] opt;
	private User user = new User();

	@Override
	public String execute() throws Exception {
		result = "/WEB-INF/site/setting/";
		return "ohimy";
	}

	/**
	 * 修改用户个人资料
	 * 
	 * @return
	 * @throws Exception
	 */
	public String personal() throws Exception {
		/* 跳转设置 */
		tab = "profilemanage_settings";
		item = "personal";
		user = userService.findUserById(getSession().getId());
		/* 下拉选项的拼装 */
		String _opt = user.getUserDetail().getHometown();
		if (_opt != null || !"".equals(_opt))
			opt = _opt.split("\\.");
		result = "/WEB-INF/site/setting/general.jsp";
		return "ohimy";
	}

	/* ************************************ */

	public String getTab() {
		return tab;
	}

	public void setTab(String tab) {
		this.tab = tab;
	}

	public String getItem() {
		return item;
	}

	public void setItem(String item) {
		this.item = item;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public String[] getOpt() {
		return opt;
	}

	public void setOpt(String[] opt) {
		this.opt = opt;
	}

}